import {Popconfirm} from 'antd';
import React from 'react';

export const articleTableColumns = (lookFun?: Function, editFun?: Function, deleteFun?: Function) => {
   return [
      {
         dataIndex: 'title',
         title: '标题',
         width: 220

      },
      {
         dataIndex: 'thumb',
         title: '缩略图',
         width: 200,
         valueType: 'image'
      },
      {
         dataIndex: 'represent',
         title: '简略描述',
         width: 240,
         ellipsis: true
      },
      {
         dataIndex: 'count',
         title: '浏览量',
         width: 100
      },
      {
         dataIndex: 'date',
         valueType: 'dateTime',
         title: '创建日期',
         width: 200
      },
      {
         title: '操作',
         valueType: 'option',
         render: (text: any, record: any, _: any, action: any) => [
            <a onClick={() => {
               lookFun && lookFun(record);
            }}>
               预览
            </a>,
            <a onClick={() => {
               editFun && editFun(record);
            }}
            >
               编辑
            </a>,
            <Popconfirm
               title='确定删除吗？'
               onConfirm={() => {
                  deleteFun && deleteFun(record);
                  action?.reset && action?.reset();
               }}
               okText='是'
               cancelText='否'
            >
               <a>删除</a>
            </Popconfirm>
         ]
      }
   ];
};


export const scenicTableColumns = (editFun?: Function, deleteFun?: Function) => {
   return [
      {
         dataIndex: 'name',
         title: '景点名',
         width: 160
      },
      {
         title: '地址',
         width: 260,
         ellipsis: true,
         render: (text: any, record: Scenic, _: any, action: any) => {
            return `经度：${record.lng},纬度：${record.lat}`;
         }
      },
      {
         dataIndex: 'videoPath',
         title: '视频地址',
         width: 240,
         ellipsis: true
      },
      {
         dataIndex: 'audioPath',
         title: '音频地址',
         width: 240,
         ellipsis: true
      },
      {
         title: '操作',
         valueType: 'option',
         width: 120,
         render: (text: any, record: any, _: any, action: any) => [

            <a onClick={() => {
               editFun && editFun(record);
            }}
            >编辑 </a>,
            <Popconfirm
               title='确定删除吗？'
               onConfirm={() => {
                  deleteFun && deleteFun(record);
                  action?.reset && action?.reset();
               }}
               okText='是'
               cancelText='否'
            >
               <a>删除</a>
            </Popconfirm>
         ]
      }
   ];
};
